import type { IPrivateRoutes } from 'types/router'
import type { RouteObject } from 'react-router-dom'
// import listRoutes from './modules/list'
// import componentRoutes from './modules/component'
// import layoutTwoRoutes from './modules/LayoutTwo'
// import multistepRoutes from './modules/multistep'
import employeeRoutes from './modules/employee'
import categoryRoutes from './modules/category'
import DishRoutes from './modules/dish'
import SetmealRoutes from './modules/setmeal'
import OrderRoutes from './modules/order'
import StatisticsRoutes from './modules/statistics'

export const privateRoutes: IPrivateRoutes[] = [
  {
    title: '演示',
    icon: 'ant-design:appstore-outlined',
    children: [StatisticsRoutes, OrderRoutes, SetmealRoutes, DishRoutes, categoryRoutes, employeeRoutes],
  },
  // {
  //   title: '系统设置',
  //   icon: 'ant-design:setting-outlined',
  //   children: [layoutTwoRoutes],
  // },
]

function addPrivateChildrenIndex(privateChildrenRoutes: RouteObject[], parentIndex: number) {
  privateChildrenRoutes.forEach((item) => {
    item.parentIndex = parentIndex
    if (item.children?.length)
      addPrivateChildrenIndex(item.children, item.parentIndex)
  })
}

function allPrivateChildrenRoutes() {
  privateRoutes.forEach((item, i) => {
    item.parentIndex = i
    if (item.children?.length)
      addPrivateChildrenIndex(item.children, item.parentIndex)
  })

  return privateRoutes.map(item => item.children).flat()
}

export default allPrivateChildrenRoutes()
